package Pattern.TemplatePattern.Program.program3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class EndlessRunerGame extends Game {

    @Override
    void initialize() {
        System.out.println("Game initialized!");
    }

    @Override
    void startPlay() {
        System.out.println("Start EndlessRunnerGame!");
    }

    @Override
    void endPlay() {
        if (playerWantsNewCharacter()) {
            System.out.println("EndlessRunnerGame Continue!");
        }else{
            System.out.println("EndlessRunnerGame Over!");
        }
    }

    @Override
    protected void addNewCharacterToTheGame() {
        System.out.println("Adding new Character to the game");
    }

    public boolean playerWantsNewCharacter() {
        String answer = getUserInput();
        if (answer.toLowerCase().startsWith("y")) {
            return true;
        } else {
            return false;
        }
    }

    private String getUserInput() {
        String answer = null;
        System.out.println("Would you like to add a new character to the game? (y/n)? ");
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        try {
            answer = bufferedReader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return answer;
    }
    //Add more methods...
}
